package crond

import (
	"context"
	"mini-app/internal/dal"
	"mini-app/internal/dao"
)

func channelUserSummary() error {
	// 统计渠道
	channelList, channelCount, _ := dao.PromotionChannel{}.List(context.Background(), dal.Q, "", 0, 0)
	if channelCount > 0 {
		for _, v := range channelList {
			// 统计渠道用户数
			_, channelUserCount, _ := dao.User{}.List(context.Background(), dal.Q, "", "", "", "", v.ID, 0, 0, 0, 0)
			// 更新渠道的注册用户数量
			dao.PromotionChannel{}.UpdateTotalMember(context.Background(), dal.Q, v.ID, channelUserCount)
		}
	}
	return nil
}
